package stock;

import java.sql.PreparedStatement;

import com.opensymphony.xwork2.ActionSupport;

import connection.MyConnection;

public class StockEntry  extends ActionSupport {
	public String item;
	public int product;
	public double weight;
	public String getItem() {
		return item;
	}
	public void setItem(String item) {
		this.item = item;
	}
	public int getProduct() {
		return product;
	}
	public void setProduct(int product) {
		this.product = product;
	}
	public double getWeight() {
		return weight;
	}
	public void setWeight(double weight) {
		this.weight = weight;
	}
	
	@Override
	
	public String execute() throws Exception
	{
		MyConnection mc = new MyConnection();
		mc.connect();
		try
		{
			PreparedStatement ps = mc.con.prepareStatement("insert into stockentry (item, product, weight) values(?,?,?)");
			ps.setString(1, item);
			ps.setInt(2, product);
			ps.setDouble(3, weight);
			ps.executeUpdate();
		}
		catch (Exception e) {
			e.printStackTrace();
			// TODO: handle exception
		}
		
		return "success";
	}

}
